<!--
 * @title: 附件组件demo
 * @author: andy.ten@tom.com & xukaixing@hotmail.com
 * @Date: 2022-05-11 11:18:06
 * @LastEditors: andy.ten@tom.com
 * @LastEditTime: 2022-06-06 13:22:45
 * @version: 1.0.4
 * @copyright: copyright (c) 2022 andyten
 *  node: you can not copy and/or use and/or modify this program free,
 *  please reserve the segment above.Please mail me if you have any question.
-->
<template>
  <ht-tabs :tab-position="tabPosition">
    <ht-tab-pane label="上传图片">
      <ht-upload :upload="upload" :remove="removeAttach" :download="download" :headers="headers" :params="params" type="pic" />
    </ht-tab-pane>
    <ht-tab-pane label="上传附件">
      <ht-upload :upload="upload" :headers="headers" :remove="removeAttach" :download="download" :params="params1" :cb="handleCb" />
    </ht-tab-pane>
    <ht-tab-pane label="附件列表">
      <ht-upload :upload="upload" :headers="headers" :remove="removeAttach" :download="download" :params="params" :cb="handleCb" />
    </ht-tab-pane>
  </ht-tabs>
</template>
<script>
import HtUpload from '@/components/HtUpload';
import { upload, removeAttach, download, setHeader } from '@/api/ht.common';
export default {
  components: {
    HtUpload
  },
  data() {
    return {
      tabPosition: 'left',
      upload: upload(),
      removeAttach: (data) => removeAttach(data),
      download: (data) => download(data),
      headers: setHeader(),
      params: { account: 'admin', bizPk: 123, folder: 'true@part.partphoto@date', isHoldName: 'false' }, // key:业务主键
      params1: { account: 'admin', bizPk: 123, folder: 'true@importTemplate', isHoldName: 'true' } // key:业务主键
    };
  },
  methods: {
    /**
     * @todo: 上传成功后回调方法
     * @author: andy.ten@tom.com & xukaixing@hotmail.com
     * @Date: 2022-05-18 22:10:14
     * @param {*} file
     */
    handleCb(file) {
      console.log(file);
    }
  }
};
</script>>
